package com.kunteng.exchangeboard.cotroller;

import com.kunteng.exchangeboard.mqtt.api.MQTTSenderHandler;
import net.sf.json.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by ShiYun on 2016/9/26 0026.
 */
public class DeviceInfo extends HttpServlet{

    MQTTSenderHandler mqttSenderHandler=new MQTTSenderHandler();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        JSONObject jsonObject=mqttSenderHandler.getDeviceInfo();
        PrintWriter printWriter = resp.getWriter();
        printWriter.println(jsonObject);
        printWriter.close();
    }
}
